package main

import (
	"fmt"
	"log"

	"server/app/http"

	"github.com/gin-gonic/gin"
	"golang.org/x/crypto/bcrypt"
)

func main() {
	r := gin.Default()

	r.POST("/login", http.Login)
	r.POST("/register", http.Register)

	err := r.Run(":8080")
	if err != nil {
		log.Fatal(err)
	}
}

func CreatePWD(s string) string { //客户端生成密文密码
	hash, err := bcrypt.GenerateFromPassword([]byte(s), bcrypt.DefaultCost)
	if err != nil {
		log.Println(err)
		return ""
	}
	s = string(hash)
	fmt.Println(s)
	return s
}
